home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD-ROM Today - The Disc! 5
/
CD-ROM Today - The Disc (Issue 5)(November 1994).ISO
/
mac
/
Mac shareware
/
Education
/
RLaB
/
examples
/
primes.r
< prev
next >
Wrap
Text File
|
1994-09-21
|
340b
|
23 lines
//
// An example that finds all primes less than limit
//
primes = function (limit) {
local(prime, cnt, i, j, k);
i = 1; j = 0; cnt = 0;
for(k in 2:limit)
{
j = 2;
while(mod(k,j) != 0) {
j++;
}
if(j == k) { // Found prime
cnt++;
prime[1;i] = k;
i++;
}
}
return prime;
}